package com.bc.bczbweb.controller;

import com.bc.commoncore.util.StringUtils;
import com.bc.commonentity.common.JsonResult;
import com.bc.bcapi.service.T_Menu_infoService;
import com.bc.bcmodel.domain.T_Menu_infoModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.math.BigInteger;

@Controller
@RequestMapping("t_menu_info")
public class T_Menu_infoController extends BaseController {
    @Autowired
    T_Menu_infoService t_Menu_infoService;

    @RequestMapping("list")
    public ModelAndView list() {
        ModelAndView view = super.baseView("列表", "t_menu_info/list");
        view.addObject("data", t_Menu_infoService.getMenuManageInfo());
        return view;
    }

    @RequestMapping("listdo")
    public ModelAndView listdo(T_Menu_infoModel req) {
        ModelAndView view = super.baseViewAjax("列表", "t_menu_info/listdo");
        view.addObject("data", t_Menu_infoService.getAllList(req));
        return view;
    }

    @RequestMapping("add")
    public ModelAndView add(T_Menu_infoModel req) {
        String title = req.getMenu_id().equals("") ? "添加" : "编辑";
        ModelAndView view = super.baseView(title, "t_menu_info/add");
        T_Menu_infoModel data = new T_Menu_infoModel();
        data.setP_id(req.getP_id());
        if (!req.getMenu_id().equals("")) {
            data = t_Menu_infoService.findByNamedParam(req);
        }
        view.addObject("data", data);
        view.addObject("title", title);
        return view;
    }

    @RequestMapping("del")
    public JsonResult del(BigInteger id) {
        JsonResult js = new JsonResult();
        t_Menu_infoService.delete(id);
        return js;
    }
}